
<!DOCTYPE HTML>
<html lang="zh-hans" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>4.JS原型和原型链 · Gary的小窝</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.3">
        <meta name="author" content="Gary">
        
        
    
    <link rel="stylesheet" href="../gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-prism/prism-solarizedlight.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-search-pro/search.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-expandable-chapters/expandable-chapters.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-splitter/splitter.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-tbfed-pagefooter/footer.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-anchor-navigation-ex/style/plugin.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-fontsettings/website.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-theme-comscore/test.css">
                
            
        

    

    

        
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="../gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="call.html" />
    
    
    <link rel="prev" href="bind.html" />
    

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="输入并搜索" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    

    

    
        
        
    
        <li class="chapter " data-level="1.1" data-path="../">
            
                <a href="../">
            
                    
                    写在前面
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="../leetcode/">
            
                <a href="../leetcode/">
            
                    
                    Leetcode之旅
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.2.1" data-path="../leetcode/1.html">
            
                <a href="../leetcode/1.html">
            
                    
                    1.两数之和
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.2" data-path="../leetcode/2.html">
            
                <a href="../leetcode/2.html">
            
                    
                    2.两数相加
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.3" data-path="../leetcode/3.html">
            
                <a href="../leetcode/3.html">
            
                    
                    3.无重复字符的最长子串
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.4" data-path="../leetcode/4.html">
            
                <a href="../leetcode/4.html">
            
                    
                    4.寻找两个有序数组的中位数
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.5" data-path="../leetcode/6.html">
            
                <a href="../leetcode/6.html">
            
                    
                    6.Z字形变换
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.6" data-path="../leetcode/9.html">
            
                <a href="../leetcode/9.html">
            
                    
                    9.回文数
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.7" data-path="../leetcode/11.html">
            
                <a href="../leetcode/11.html">
            
                    
                    11.盛最多水的容器
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.8" data-path="../leetcode/12.html">
            
                <a href="../leetcode/12.html">
            
                    
                    12.整数转罗马数字
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.9" data-path="../leetcode/13.html">
            
                <a href="../leetcode/13.html">
            
                    
                    13.罗马数字转整数
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.10" data-path="../leetcode/14.html">
            
                <a href="../leetcode/14.html">
            
                    
                    14.最长公共前缀
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.11" data-path="../leetcode/322.html">
            
                <a href="../leetcode/322.html">
            
                    
                    322.零钱兑换
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.12" data-path="../leetcode/72.html">
            
                <a href="../leetcode/72.html">
            
                    
                    72.编辑距离
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.3" data-path="../flutter/">
            
                <a href="../flutter/">
            
                    
                    Flutter从入门到放弃
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.3.1" data-path="../flutter/dart1.html">
            
                <a href="../flutter/dart1.html">
            
                    
                    1.Dart语言(1)
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.2" data-path="../flutter/dart2.html">
            
                <a href="../flutter/dart2.html">
            
                    
                    2.Dart语言(2)
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.3" data-path="../flutter/widget1.html">
            
                <a href="../flutter/widget1.html">
            
                    
                    3.Flutter初始化
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.4" data-path="../flutter/containerText.html">
            
                <a href="../flutter/containerText.html">
            
                    
                    4.Container和Text组件
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.5" data-path="../flutter/image.html">
            
                <a href="../flutter/image.html">
            
                    
                    5.Image组件
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.6" data-path="../flutter/chapter2.html">
            
                <a href="../flutter/chapter2.html">
            
                    
                    6.Flutter 技术总结
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.4" data-path="../vue/">
            
                <a href="../vue/">
            
                    
                    Vue组件精讲
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.4.1" data-path="../vue/1.html">
            
                <a href="../vue/1.html">
            
                    
                    1.provide/inject
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.2" data-path="../vue/2.html">
            
                <a href="../vue/2.html">
            
                    
                    2.手动实现broadcast和dispatch方法
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.3" data-path="form.html">
            
                <a href="form.html">
            
                    
                    3.自己动手实现带校验的Form表单组件
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.5" data-path="./">
            
                <a href="./">
            
                    
                    JavaScript进阶
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.5.1" data-path="proxy.html">
            
                <a href="proxy.html">
            
                    
                    1.Vue.js 3.0中的响应式
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.2" data-path="el.html">
            
                <a href="el.html">
            
                    
                    2.Element UI 源码初探
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.3" data-path="bind.html">
            
                <a href="bind.html">
            
                    
                    3.bind的模拟实现
            
                </a>
            

            
        </li>
    
        <li class="chapter active" data-level="1.5.4" data-path="proto.html">
            
                <a href="proto.html">
            
                    
                    4.JS原型和原型链
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.5" data-path="call.html">
            
                <a href="call.html">
            
                    
                    5.模拟实现call和apply
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.6" data-path="ui.html">
            
                <a href="ui.html">
            
                    
                    6.使用Vue cli3搭建组件库并发布到 npm
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.7" data-path="microFE.html">
            
                <a href="microFE.html">
            
                    
                    7.记一次基于qiankun的微前端的改造
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.8" data-path="git.html">
            
                <a href="git.html">
            
                    
                    8.Git的使用
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.6" data-path="../vueLibrary/">
            
                <a href="../vueLibrary/">
            
                    
                    基于Vue的PC端的组件库
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.6.1" data-path="../vueLibrary/1.html">
            
                <a href="../vueLibrary/1.html">
            
                    
                    1.环境搭建
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.7" data-path="../life/">
            
                <a href="../life/">
            
                    
                    网事杂谈
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.7.1" data-path="../life/1.html">
            
                <a href="../life/1.html">
            
                    
                    1.周杰伦专辑赏析--叶惠美
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.2" data-path="../life/2.html">
            
                <a href="../life/2.html">
            
                    
                    2.周杰伦专辑赏析--七里香
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            本书使用 GitBook 发布
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href=".." >4.JS原型和原型链</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <div id="anchor-navigation-ex-navbar"><i class="fa fa-navicon"></i><ul><li><span class="title-icon "></span><a href="#javascript&#x8FDB;&#x9636;&#x4E4B;&#x4ECE;&#x539F;&#x578B;&#x5230;&#x539F;&#x578B;&#x94FE;"><b></b>JavaScript&#x8FDB;&#x9636;&#x4E4B;&#x4ECE;&#x539F;&#x578B;&#x5230;&#x539F;&#x578B;&#x94FE;</a></li><ul><li><span class="title-icon "></span><a href="#&#x6784;&#x9020;&#x51FD;&#x6570;&#x521B;&#x5EFA;&#x5BF9;&#x8C61;"><b></b>&#x6784;&#x9020;&#x51FD;&#x6570;&#x521B;&#x5EFA;&#x5BF9;&#x8C61;</a></li><li><span class="title-icon "></span><a href="#prototype"><b></b>prototype</a></li><li><span class="title-icon "></span><a href="#proto"><b></b>__proto__</a></li><li><span class="title-icon "></span><a href="#constructor_function%20Object()%20%7B%20[native%20code]%20%7D"><b></b>constructor</a></li><li><span class="title-icon "></span><a href="#&#x5B9E;&#x4F8B;&#x4E0E;&#x539F;&#x578B;"><b></b>&#x5B9E;&#x4F8B;&#x4E0E;&#x539F;&#x578B;</a></li><li><span class="title-icon "></span><a href="#&#x539F;&#x578B;&#x7684;&#x539F;&#x578B;"><b></b>&#x539F;&#x578B;&#x7684;&#x539F;&#x578B;</a></li><li><span class="title-icon "></span><a href="#&#x539F;&#x578B;&#x94FE;"><b></b>&#x539F;&#x578B;&#x94FE;</a></li><li><span class="title-icon "></span><a href="#&#x8865;&#x5145;"><b></b>&#x8865;&#x5145;</a></li><ul><li><span class="title-icon "></span><a href="#constructor_function%20Object()%20%7B%20[native%20code]%20%7D1"><b></b>constructor</a></li><li><span class="title-icon "></span><a href="#proto_1"><b></b>__proto__</a></li><li><span class="title-icon "></span><a href="#&#x771F;&#x7684;&#x662F;&#x7EE7;&#x627F;&#x5417;&#xFF1F;"><b></b>&#x771F;&#x7684;&#x662F;&#x7EE7;&#x627F;&#x5417;&#xFF1F;</a></li></ul></ul></ul></div><a href="#javascript&#x8FDB;&#x9636;&#x4E4B;&#x4ECE;&#x539F;&#x578B;&#x5230;&#x539F;&#x578B;&#x94FE;" id="anchorNavigationExGoTop"><i class="fa fa-arrow-up"></i></a><h1 id="javascript&#x8FDB;&#x9636;&#x4E4B;&#x4ECE;&#x539F;&#x578B;&#x5230;&#x539F;&#x578B;&#x94FE;"><a name="javascript&#x8FDB;&#x9636;&#x4E4B;&#x4ECE;&#x539F;&#x578B;&#x5230;&#x539F;&#x578B;&#x94FE;" class="anchor-navigation-ex-anchor" href="#javascript&#x8FDB;&#x9636;&#x4E4B;&#x4ECE;&#x539F;&#x578B;&#x5230;&#x539F;&#x578B;&#x94FE;"><i class="fa fa-link" aria-hidden="true"></i></a>JavaScript&#x8FDB;&#x9636;&#x4E4B;&#x4ECE;&#x539F;&#x578B;&#x5230;&#x539F;&#x578B;&#x94FE;</h1>
<h2 id="&#x6784;&#x9020;&#x51FD;&#x6570;&#x521B;&#x5EFA;&#x5BF9;&#x8C61;"><a name="&#x6784;&#x9020;&#x51FD;&#x6570;&#x521B;&#x5EFA;&#x5BF9;&#x8C61;" class="anchor-navigation-ex-anchor" href="#&#x6784;&#x9020;&#x51FD;&#x6570;&#x521B;&#x5EFA;&#x5BF9;&#x8C61;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x6784;&#x9020;&#x51FD;&#x6570;&#x521B;&#x5EFA;&#x5BF9;&#x8C61;</h2>
<p>&#x6211;&#x4EEC;&#x5148;&#x4F7F;&#x7528;&#x6784;&#x9020;&#x51FD;&#x6570;&#x521B;&#x5EFA;&#x4E00;&#x4E2A;&#x5BF9;&#x8C61;&#xFF1A;</p>
<pre class="language-"><code class="lang-js"><span class="token keyword">function</span> <span class="token function">Person</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>

<span class="token punctuation">}</span>
<span class="token keyword">var</span> person <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">Person</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
person<span class="token punctuation">.</span>name <span class="token operator">=</span> <span class="token string">&apos;Kevin&apos;</span><span class="token punctuation">;</span>
console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span>person<span class="token punctuation">.</span>name<span class="token punctuation">)</span> <span class="token comment">// Kevin</span>
</code></pre>
<p>&#x5728;&#x8FD9;&#x4E2A;&#x4F8B;&#x5B50;&#x4E2D;&#xFF0C;Person &#x5C31;&#x662F;&#x4E00;&#x4E2A;&#x6784;&#x9020;&#x51FD;&#x6570;&#xFF0C;&#x6211;&#x4EEC;&#x4F7F;&#x7528; new &#x521B;&#x5EFA;&#x4E86;&#x4E00;&#x4E2A;&#x5B9E;&#x4F8B;&#x5BF9;&#x8C61; person&#x3002;</p>
<p>&#x5F88;&#x7B80;&#x5355;&#x5427;&#xFF0C;&#x63A5;&#x4E0B;&#x6765;&#x8FDB;&#x5165;&#x6B63;&#x9898;&#xFF1A;</p>
<h2 id="prototype"><a name="prototype" class="anchor-navigation-ex-anchor" href="#prototype"><i class="fa fa-link" aria-hidden="true"></i></a>prototype</h2>
<p>&#x6BCF;&#x4E2A;&#x51FD;&#x6570;&#x90FD;&#x6709;&#x4E00;&#x4E2A; prototype &#x5C5E;&#x6027;&#xFF0C;&#x5C31;&#x662F;&#x6211;&#x4EEC;&#x7ECF;&#x5E38;&#x5728;&#x5404;&#x79CD;&#x4F8B;&#x5B50;&#x4E2D;&#x770B;&#x5230;&#x7684;&#x90A3;&#x4E2A; prototype &#xFF0C;&#x6BD4;&#x5982;&#xFF1A;</p>
<pre class="language-"><code class="lang-js"><span class="token keyword">function</span> <span class="token function">Person</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>

<span class="token punctuation">}</span>
<span class="token comment">// &#x867D;&#x7136;&#x5199;&#x5728;&#x6CE8;&#x91CA;&#x91CC;&#xFF0C;&#x4F46;&#x662F;&#x4F60;&#x8981;&#x6CE8;&#x610F;&#xFF1A;</span>
<span class="token comment">// prototype&#x662F;&#x51FD;&#x6570;&#x624D;&#x4F1A;&#x6709;&#x7684;&#x5C5E;&#x6027;</span>
<span class="token class-name">Person</span><span class="token punctuation">.</span>prototype<span class="token punctuation">.</span>name <span class="token operator">=</span> <span class="token string">&apos;Kevin&apos;</span><span class="token punctuation">;</span>
<span class="token keyword">var</span> person1 <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">Person</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">var</span> person2 <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">Person</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span>person1<span class="token punctuation">.</span>name<span class="token punctuation">)</span> <span class="token comment">// Kevin</span>
console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span>person2<span class="token punctuation">.</span>name<span class="token punctuation">)</span> <span class="token comment">// Kevin</span>
</code></pre>
<p>&#x90A3;&#x8FD9;&#x4E2A;&#x51FD;&#x6570;&#x7684; prototype &#x5C5E;&#x6027;&#x5230;&#x5E95;&#x6307;&#x5411;&#x7684;&#x662F;&#x4EC0;&#x4E48;&#x5462;&#xFF1F;&#x662F;&#x8FD9;&#x4E2A;&#x51FD;&#x6570;&#x7684;&#x539F;&#x578B;&#x5417;&#xFF1F;</p>
<p>&#x5176;&#x5B9E;&#xFF0C;&#x51FD;&#x6570;&#x7684; prototype &#x5C5E;&#x6027;&#x6307;&#x5411;&#x4E86;&#x4E00;&#x4E2A;&#x5BF9;&#x8C61;&#xFF0C;&#x8FD9;&#x4E2A;&#x5BF9;&#x8C61;&#x6B63;&#x662F;&#x8C03;&#x7528;&#x8BE5;&#x6784;&#x9020;&#x51FD;&#x6570;&#x800C;&#x521B;&#x5EFA;&#x7684;<strong>&#x5B9E;&#x4F8B;</strong>&#x7684;&#x539F;&#x578B;&#xFF0C;&#x4E5F;&#x5C31;&#x662F;&#x8FD9;&#x4E2A;&#x4F8B;&#x5B50;&#x4E2D;&#x7684; person1 &#x548C; person2 &#x7684;&#x539F;&#x578B;&#x3002;</p>
<p>&#x90A3;&#x4EC0;&#x4E48;&#x662F;&#x539F;&#x578B;&#x5462;&#xFF1F;&#x4F60;&#x53EF;&#x4EE5;&#x8FD9;&#x6837;&#x7406;&#x89E3;&#xFF1A;&#x6BCF;&#x4E00;&#x4E2A;JavaScript&#x5BF9;&#x8C61;(null&#x9664;&#x5916;)&#x5728;&#x521B;&#x5EFA;&#x7684;&#x65F6;&#x5019;&#x5C31;&#x4F1A;&#x4E0E;&#x4E4B;&#x5173;&#x8054;&#x53E6;&#x4E00;&#x4E2A;&#x5BF9;&#x8C61;&#xFF0C;&#x8FD9;&#x4E2A;&#x5BF9;&#x8C61;&#x5C31;&#x662F;&#x6211;&#x4EEC;&#x6240;&#x8BF4;&#x7684;&#x539F;&#x578B;&#xFF0C;&#x6BCF;&#x4E00;&#x4E2A;&#x5BF9;&#x8C61;&#x90FD;&#x4F1A;&#x4ECE;&#x539F;&#x578B;&quot;&#x7EE7;&#x627F;&quot;&#x5C5E;&#x6027;&#x3002;</p>
<p>&#x8BA9;&#x6211;&#x4EEC;&#x7528;&#x4E00;&#x5F20;&#x56FE;&#x8868;&#x793A;&#x6784;&#x9020;&#x51FD;&#x6570;&#x548C;&#x5B9E;&#x4F8B;&#x539F;&#x578B;&#x4E4B;&#x95F4;&#x7684;&#x5173;&#x7CFB;&#xFF1A;</p>
<p><img src="https://i.loli.net/2019/10/24/zHBC6mI9RcZJklA.png" alt="&#x6784;&#x9020;&#x51FD;&#x6570;&#x548C;&#x5B9E;&#x4F8B;&#x539F;&#x578B;&#x7684;&#x5173;&#x7CFB;&#x56FE;"></p>
<p>&#x5728;&#x8FD9;&#x5F20;&#x56FE;&#x4E2D;&#x6211;&#x4EEC;&#x7528; Object.prototype &#x8868;&#x793A;&#x5B9E;&#x4F8B;&#x539F;&#x578B;&#x3002;</p>
<p>&#x90A3;&#x4E48;&#x6211;&#x4EEC;&#x8BE5;&#x600E;&#x4E48;&#x8868;&#x793A;&#x5B9E;&#x4F8B;&#x4E0E;&#x5B9E;&#x4F8B;&#x539F;&#x578B;&#xFF0C;&#x4E5F;&#x5C31;&#x662F; person &#x548C; Person.prototype &#x4E4B;&#x95F4;&#x7684;&#x5173;&#x7CFB;&#x5462;&#xFF0C;&#x8FD9;&#x65F6;&#x5019;&#x6211;&#x4EEC;&#x5C31;&#x8981;&#x8BB2;&#x5230;&#x7B2C;&#x4E8C;&#x4E2A;&#x5C5E;&#x6027;&#xFF1A;</p>
<h2 id="proto"><a name="proto" class="anchor-navigation-ex-anchor" href="#proto"><i class="fa fa-link" aria-hidden="true"></i></a>__proto__</h2>
<p>&#x8FD9;&#x662F;&#x6BCF;&#x4E00;&#x4E2A;JavaScript&#x5BF9;&#x8C61;(&#x9664;&#x4E86; null )&#x90FD;&#x5177;&#x6709;&#x7684;&#x4E00;&#x4E2A;&#x5C5E;&#x6027;&#xFF0C;&#x53EB;__proto__&#xFF0C;&#x8FD9;&#x4E2A;&#x5C5E;&#x6027;&#x4F1A;&#x6307;&#x5411;&#x8BE5;&#x5BF9;&#x8C61;&#x7684;&#x539F;&#x578B;&#x3002;</p>
<p>&#x4E3A;&#x4E86;&#x8BC1;&#x660E;&#x8FD9;&#x4E00;&#x70B9;,&#x6211;&#x4EEC;&#x53EF;&#x4EE5;&#x5728;&#x706B;&#x72D0;&#x6216;&#x8005;&#x8C37;&#x6B4C;&#x4E2D;&#x8F93;&#x5165;&#xFF1A;</p>
<pre class="language-"><code class="lang-js"><span class="token keyword">function</span> <span class="token function">Person</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>

<span class="token punctuation">}</span>
<span class="token keyword">var</span> person <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">Person</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span>person<span class="token punctuation">.</span>__proto__ <span class="token operator">===</span> <span class="token class-name">Person</span><span class="token punctuation">.</span>prototype<span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token comment">// true</span>
</code></pre>
<p>&#x4E8E;&#x662F;&#x6211;&#x4EEC;&#x66F4;&#x65B0;&#x4E0B;&#x5173;&#x7CFB;&#x56FE;&#xFF1A;</p>
<p><img src="https://i.loli.net/2019/10/24/wPL5r9ajEtGuhKZ.png" alt="&#x5B9E;&#x4F8B;&#x4E0E;&#x5B9E;&#x4F8B;&#x539F;&#x578B;&#x7684;&#x5173;&#x7CFB;&#x56FE;"></p>
<p>&#x65E2;&#x7136;&#x5B9E;&#x4F8B;&#x5BF9;&#x8C61;&#x548C;&#x6784;&#x9020;&#x51FD;&#x6570;&#x90FD;&#x53EF;&#x4EE5;&#x6307;&#x5411;&#x539F;&#x578B;&#xFF0C;&#x90A3;&#x4E48;&#x539F;&#x578B;&#x662F;&#x5426;&#x6709;&#x5C5E;&#x6027;&#x6307;&#x5411;&#x6784;&#x9020;&#x51FD;&#x6570;&#x6216;&#x8005;&#x5B9E;&#x4F8B;&#x5462;&#xFF1F;</p>
<h2 id="constructor_function Object() { [native code] }"><a name="constructor_function Object() { [native code] }" class="anchor-navigation-ex-anchor" href="#constructor_function%20Object()%20%7B%20[native%20code]%20%7D"><i class="fa fa-link" aria-hidden="true"></i></a>constructor</h2>
<p>&#x6307;&#x5411;&#x5B9E;&#x4F8B;&#x5012;&#x662F;&#x6CA1;&#x6709;&#xFF0C;&#x56E0;&#x4E3A;&#x4E00;&#x4E2A;&#x6784;&#x9020;&#x51FD;&#x6570;&#x53EF;&#x4EE5;&#x751F;&#x6210;&#x591A;&#x4E2A;&#x5B9E;&#x4F8B;&#xFF0C;&#x4F46;&#x662F;&#x539F;&#x578B;&#x6307;&#x5411;&#x6784;&#x9020;&#x51FD;&#x6570;&#x5012;&#x662F;&#x6709;&#x7684;&#xFF0C;&#x8FD9;&#x5C31;&#x8981;&#x8BB2;&#x5230;&#x7B2C;&#x4E09;&#x4E2A;&#x5C5E;&#x6027;&#xFF1A;constructor&#xFEFF;&#xFF0C;&#x6BCF;&#x4E2A;&#x539F;&#x578B;&#x90FD;&#x6709;&#x4E00;&#x4E2A; constructor &#x5C5E;&#x6027;&#x6307;&#x5411;&#x5173;&#x8054;&#x7684;&#x6784;&#x9020;&#x51FD;&#x6570;&#x3002;</p>
<p>&#x4E3A;&#x4E86;&#x9A8C;&#x8BC1;&#x8FD9;&#x4E00;&#x70B9;&#xFF0C;&#x6211;&#x4EEC;&#x53EF;&#x4EE5;&#x5C1D;&#x8BD5;&#xFF1A;</p>
<pre class="language-"><code class="lang-js"><span class="token keyword">function</span> <span class="token function">Person</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>

<span class="token punctuation">}</span>
console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span>Person <span class="token operator">===</span> <span class="token class-name">Person</span><span class="token punctuation">.</span>prototype<span class="token punctuation">.</span>constructor<span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token comment">// true</span>
</code></pre>
<p>&#x6240;&#x4EE5;&#x518D;&#x66F4;&#x65B0;&#x4E0B;&#x5173;&#x7CFB;&#x56FE;&#xFF1A;</p>
<p><img src="https://i.loli.net/2019/10/24/SDKEQosX5JMwy4b.png" alt="&#x5B9E;&#x4F8B;&#x539F;&#x578B;&#x4E0E;&#x6784;&#x9020;&#x51FD;&#x6570;&#x7684;&#x5173;&#x7CFB;&#x56FE;"></p>
<p>&#x7EFC;&#x4E0A;&#x6211;&#x4EEC;&#x5DF2;&#x7ECF;&#x5F97;&#x51FA;&#xFF1A;</p>
<pre class="language-"><code class="lang-js"><span class="token keyword">function</span> <span class="token function">Person</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>

<span class="token punctuation">}</span>

<span class="token keyword">var</span> person <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">Person</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span>person<span class="token punctuation">.</span>__proto__ <span class="token operator">==</span> <span class="token class-name">Person</span><span class="token punctuation">.</span>prototype<span class="token punctuation">)</span> <span class="token comment">// true</span>
console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span><span class="token class-name">Person</span><span class="token punctuation">.</span>prototype<span class="token punctuation">.</span>constructor <span class="token operator">==</span> Person<span class="token punctuation">)</span> <span class="token comment">// true</span>
<span class="token comment">// &#x987A;&#x4FBF;&#x5B66;&#x4E60;&#x4E00;&#x4E2A;ES5&#x7684;&#x65B9;&#x6CD5;,&#x53EF;&#x4EE5;&#x83B7;&#x5F97;&#x5BF9;&#x8C61;&#x7684;&#x539F;&#x578B;</span>
console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span>Object<span class="token punctuation">.</span><span class="token function">getPrototypeOf</span><span class="token punctuation">(</span>person<span class="token punctuation">)</span> <span class="token operator">===</span> <span class="token class-name">Person</span><span class="token punctuation">.</span>prototype<span class="token punctuation">)</span> <span class="token comment">// true</span>
</code></pre>
<p>&#x4E86;&#x89E3;&#x4E86;&#x6784;&#x9020;&#x51FD;&#x6570;&#x3001;&#x5B9E;&#x4F8B;&#x539F;&#x578B;&#x3001;&#x548C;&#x5B9E;&#x4F8B;&#x4E4B;&#x95F4;&#x7684;&#x5173;&#x7CFB;&#xFF0C;&#x63A5;&#x4E0B;&#x6765;&#x6211;&#x4EEC;&#x8BB2;&#x8BB2;&#x5B9E;&#x4F8B;&#x548C;&#x539F;&#x578B;&#x7684;&#x5173;&#x7CFB;&#xFF1A;</p>
<h2 id="&#x5B9E;&#x4F8B;&#x4E0E;&#x539F;&#x578B;"><a name="&#x5B9E;&#x4F8B;&#x4E0E;&#x539F;&#x578B;" class="anchor-navigation-ex-anchor" href="#&#x5B9E;&#x4F8B;&#x4E0E;&#x539F;&#x578B;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x5B9E;&#x4F8B;&#x4E0E;&#x539F;&#x578B;</h2>
<p>&#x5F53;&#x8BFB;&#x53D6;&#x5B9E;&#x4F8B;&#x7684;&#x5C5E;&#x6027;&#x65F6;&#xFF0C;&#x5982;&#x679C;&#x627E;&#x4E0D;&#x5230;&#xFF0C;&#x5C31;&#x4F1A;&#x67E5;&#x627E;&#x4E0E;&#x5BF9;&#x8C61;&#x5173;&#x8054;&#x7684;&#x539F;&#x578B;&#x4E2D;&#x7684;&#x5C5E;&#x6027;&#xFF0C;&#x5982;&#x679C;&#x8FD8;&#x67E5;&#x4E0D;&#x5230;&#xFF0C;&#x5C31;&#x53BB;&#x627E;&#x539F;&#x578B;&#x7684;&#x539F;&#x578B;&#xFF0C;&#x4E00;&#x76F4;&#x627E;&#x5230;&#x6700;&#x9876;&#x5C42;&#x4E3A;&#x6B62;&#x3002;</p>
<p>&#x4E3E;&#x4E2A;&#x4F8B;&#x5B50;&#xFF1A;</p>
<pre class="language-"><code class="lang-js"><span class="token keyword">function</span> <span class="token function">Person</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>

<span class="token punctuation">}</span>

<span class="token class-name">Person</span><span class="token punctuation">.</span>prototype<span class="token punctuation">.</span>name <span class="token operator">=</span> <span class="token string">&apos;Kevin&apos;</span><span class="token punctuation">;</span>

<span class="token keyword">var</span> person <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">Person</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

person<span class="token punctuation">.</span>name <span class="token operator">=</span> <span class="token string">&apos;Daisy&apos;</span><span class="token punctuation">;</span>
console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span>person<span class="token punctuation">.</span>name<span class="token punctuation">)</span> <span class="token comment">// Daisy</span>

<span class="token keyword">delete</span> person<span class="token punctuation">.</span>name<span class="token punctuation">;</span>
console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span>person<span class="token punctuation">.</span>name<span class="token punctuation">)</span> <span class="token comment">// Kevin</span>
</code></pre>
<p>&#x5728;&#x8FD9;&#x4E2A;&#x4F8B;&#x5B50;&#x4E2D;&#xFF0C;&#x6211;&#x4EEC;&#x7ED9;&#x5B9E;&#x4F8B;&#x5BF9;&#x8C61; person &#x6DFB;&#x52A0;&#x4E86; name &#x5C5E;&#x6027;&#xFF0C;&#x5F53;&#x6211;&#x4EEC;&#x6253;&#x5370; person.name &#x7684;&#x65F6;&#x5019;&#xFF0C;&#x7ED3;&#x679C;&#x81EA;&#x7136;&#x4E3A; Daisy&#x3002;</p>
<p>&#x4F46;&#x662F;&#x5F53;&#x6211;&#x4EEC;&#x5220;&#x9664;&#x4E86; person &#x7684; name &#x5C5E;&#x6027;&#x65F6;&#xFF0C;&#x8BFB;&#x53D6; person.name&#xFF0C;&#x4ECE; person &#x5BF9;&#x8C61;&#x4E2D;&#x627E;&#x4E0D;&#x5230; name &#x5C5E;&#x6027;&#x5C31;&#x4F1A;&#x4ECE; person &#x7684;&#x539F;&#x578B;&#x4E5F;&#x5C31;&#x662F; person.__proto__ &#xFF0C;&#x4E5F;&#x5C31;&#x662F; Person.prototype&#x4E2D;&#x67E5;&#x627E;&#xFF0C;&#x5E78;&#x8FD0;&#x7684;&#x662F;&#x6211;&#x4EEC;&#x627E;&#x5230;&#x4E86;  name &#x5C5E;&#x6027;&#xFF0C;&#x7ED3;&#x679C;&#x4E3A; Kevin&#x3002;</p>
<p>&#x4F46;&#x662F;&#x4E07;&#x4E00;&#x8FD8;&#x6CA1;&#x6709;&#x627E;&#x5230;&#x5462;&#xFF1F;&#x539F;&#x578B;&#x7684;&#x539F;&#x578B;&#x53C8;&#x662F;&#x4EC0;&#x4E48;&#x5462;&#xFF1F;</p>
<h2 id="&#x539F;&#x578B;&#x7684;&#x539F;&#x578B;"><a name="&#x539F;&#x578B;&#x7684;&#x539F;&#x578B;" class="anchor-navigation-ex-anchor" href="#&#x539F;&#x578B;&#x7684;&#x539F;&#x578B;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x539F;&#x578B;&#x7684;&#x539F;&#x578B;</h2>
<p>&#x5728;&#x524D;&#x9762;&#xFF0C;&#x6211;&#x4EEC;&#x5DF2;&#x7ECF;&#x8BB2;&#x4E86;&#x539F;&#x578B;&#x4E5F;&#x662F;&#x4E00;&#x4E2A;&#x5BF9;&#x8C61;&#xFF0C;&#x65E2;&#x7136;&#x662F;&#x5BF9;&#x8C61;&#xFF0C;&#x6211;&#x4EEC;&#x5C31;&#x53EF;&#x4EE5;&#x7528;&#x6700;&#x539F;&#x59CB;&#x7684;&#x65B9;&#x5F0F;&#x521B;&#x5EFA;&#x5B83;&#xFF0C;&#x90A3;&#x5C31;&#x662F;&#xFF1A;</p>
<pre class="language-"><code class="lang-js"><span class="token keyword">var</span> obj <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">Object</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
obj<span class="token punctuation">.</span>name <span class="token operator">=</span> <span class="token string">&apos;Kevin&apos;</span>
console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span>obj<span class="token punctuation">.</span>name<span class="token punctuation">)</span> <span class="token comment">// Kevin</span>
</code></pre>
<p>&#x6240;&#x4EE5;&#x539F;&#x578B;&#x5BF9;&#x8C61;&#x662F;&#x901A;&#x8FC7; Object &#x6784;&#x9020;&#x51FD;&#x6570;&#x751F;&#x6210;&#x7684;&#xFF0C;&#x7ED3;&#x5408;&#x4E4B;&#x524D;&#x6240;&#x8BB2;&#xFF0C;&#x5B9E;&#x4F8B;&#x7684; __proto__ &#x6307;&#x5411;&#x6784;&#x9020;&#x51FD;&#x6570;&#x7684; prototype &#xFF0C;&#x6240;&#x4EE5;&#x6211;&#x4EEC;&#x518D;&#x66F4;&#x65B0;&#x4E0B;&#x5173;&#x7CFB;&#x56FE;&#xFF1A;</p>
<p><img src="https://i.loli.net/2019/10/24/bMav3xYLy8CRNOo.png" alt="&#x539F;&#x578B;&#x7684;&#x539F;&#x578B;&#x5173;&#x7CFB;&#x56FE;"></p>
<h2 id="&#x539F;&#x578B;&#x94FE;"><a name="&#x539F;&#x578B;&#x94FE;" class="anchor-navigation-ex-anchor" href="#&#x539F;&#x578B;&#x94FE;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x539F;&#x578B;&#x94FE;</h2>
<p>&#x90A3; Object.prototype &#x7684;&#x539F;&#x578B;&#x5462;&#xFF1F;</p>
<p>null&#xFF0C;&#x6211;&#x4EEC;&#x53EF;&#x4EE5;&#x6253;&#x5370;&#xFF1A;</p>
<pre class="language-"><code class="lang-js">console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span><span class="token class-name">Object</span><span class="token punctuation">.</span>prototype<span class="token punctuation">.</span>__proto__ <span class="token operator">===</span> <span class="token keyword">null</span><span class="token punctuation">)</span> <span class="token comment">// true</span>
</code></pre>
<p>&#x7136;&#x800C; null &#x7A76;&#x7ADF;&#x4EE3;&#x8868;&#x4E86;&#x4EC0;&#x4E48;&#x5462;&#xFF1F;</p>
<p>&#x5F15;&#x7528;&#x962E;&#x4E00;&#x5CF0;&#x8001;&#x5E08;&#x7684; <a href="http://www.ruanyifeng.com/blog/2014/03/undefined-vs-null.html" target="_blank">&#x300A;undefined&#x4E0E;null&#x7684;&#x533A;&#x522B;&#x300B;</a> &#x5C31;&#x662F;&#xFF1A;</p>
<blockquote>
<p>null &#x8868;&#x793A;&#x201C;&#x6CA1;&#x6709;&#x5BF9;&#x8C61;&#x201D;&#xFF0C;&#x5373;&#x8BE5;&#x5904;&#x4E0D;&#x5E94;&#x8BE5;&#x6709;&#x503C;&#x3002;</p>
</blockquote>
<p>&#x6240;&#x4EE5; Object.prototype.__proto__ &#x7684;&#x503C;&#x4E3A; null &#x8DDF; Object.prototype &#x6CA1;&#x6709;&#x539F;&#x578B;&#xFF0C;&#x5176;&#x5B9E;&#x8868;&#x8FBE;&#x4E86;&#x4E00;&#x4E2A;&#x610F;&#x601D;&#x3002;</p>
<p>&#x6240;&#x4EE5;&#x67E5;&#x627E;&#x5C5E;&#x6027;&#x7684;&#x65F6;&#x5019;&#x67E5;&#x5230; Object.prototype &#x5C31;&#x53EF;&#x4EE5;&#x505C;&#x6B62;&#x67E5;&#x627E;&#x4E86;&#x3002;</p>
<p>&#x6700;&#x540E;&#x4E00;&#x5F20;&#x5173;&#x7CFB;&#x56FE;&#x4E5F;&#x53EF;&#x4EE5;&#x66F4;&#x65B0;&#x4E3A;&#xFF1A;</p>
<p><img src="https://i.loli.net/2019/10/24/mTEvQXyRair7FC6.png" alt="&#x539F;&#x578B;&#x94FE;&#x793A;&#x610F;&#x56FE;"></p>
<p>&#x987A;&#x4FBF;&#x8FD8;&#x8981;&#x8BF4;&#x4E00;&#x4E0B;&#xFF0C;&#x56FE;&#x4E2D;&#x7531;&#x76F8;&#x4E92;&#x5173;&#x8054;&#x7684;&#x539F;&#x578B;&#x7EC4;&#x6210;&#x7684;&#x94FE;&#x72B6;&#x7ED3;&#x6784;&#x5C31;&#x662F;&#x539F;&#x578B;&#x94FE;&#xFF0C;&#x4E5F;&#x5C31;&#x662F;&#x84DD;&#x8272;&#x7684;&#x8FD9;&#x6761;&#x7EBF;&#x3002;</p>
<h2 id="&#x8865;&#x5145;"><a name="&#x8865;&#x5145;" class="anchor-navigation-ex-anchor" href="#&#x8865;&#x5145;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x8865;&#x5145;</h2>
<p>&#x6700;&#x540E;&#xFF0C;&#x8865;&#x5145;&#x4E09;&#x70B9;&#x5927;&#x5BB6;&#x53EF;&#x80FD;&#x4E0D;&#x4F1A;&#x6CE8;&#x610F;&#x7684;&#x5730;&#x65B9;&#xFF1A;</p>
<h3 id="constructor_function Object() { [native code] }1"><a name="constructor_function Object() { [native code] }1" class="anchor-navigation-ex-anchor" href="#constructor_function%20Object()%20%7B%20[native%20code]%20%7D1"><i class="fa fa-link" aria-hidden="true"></i></a>constructor</h3>
<p>&#x9996;&#x5148;&#x662F; constructor &#x5C5E;&#x6027;&#xFF0C;&#x6211;&#x4EEC;&#x770B;&#x4E2A;&#x4F8B;&#x5B50;&#xFF1A;</p>
<pre class="language-"><code class="lang-js"><span class="token keyword">function</span> <span class="token function">Person</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>

<span class="token punctuation">}</span>
<span class="token keyword">var</span> person <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">Person</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span>person<span class="token punctuation">.</span>constructor <span class="token operator">===</span> Person<span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token comment">// true</span>
</code></pre>
<p>&#x5F53;&#x83B7;&#x53D6; person.constructor &#x65F6;&#xFF0C;&#x5176;&#x5B9E; person &#x4E2D;&#x5E76;&#x6CA1;&#x6709; constructor &#x5C5E;&#x6027;,&#x5F53;&#x4E0D;&#x80FD;&#x8BFB;&#x53D6;&#x5230;constructor &#x5C5E;&#x6027;&#x65F6;&#xFF0C;&#x4F1A;&#x4ECE; person &#x7684;&#x539F;&#x578B;&#x4E5F;&#x5C31;&#x662F; Person.prototype &#x4E2D;&#x8BFB;&#x53D6;&#xFF0C;&#x6B63;&#x597D;&#x539F;&#x578B;&#x4E2D;&#x6709;&#x8BE5;&#x5C5E;&#x6027;&#xFF0C;&#x6240;&#x4EE5;&#xFF1A;</p>
<pre class="language-"><code class="lang-js">person<span class="token punctuation">.</span>constructor <span class="token operator">===</span> <span class="token class-name">Person</span><span class="token punctuation">.</span>prototype<span class="token punctuation">.</span>constructor
</code></pre>
<h3 id="proto_1"><a name="proto_1" class="anchor-navigation-ex-anchor" href="#proto_1"><i class="fa fa-link" aria-hidden="true"></i></a>__proto__</h3>
<p>&#x5176;&#x6B21;&#x662F; __proto__ &#xFF0C;&#x7EDD;&#x5927;&#x90E8;&#x5206;&#x6D4F;&#x89C8;&#x5668;&#x90FD;&#x652F;&#x6301;&#x8FD9;&#x4E2A;&#x975E;&#x6807;&#x51C6;&#x7684;&#x65B9;&#x6CD5;&#x8BBF;&#x95EE;&#x539F;&#x578B;&#xFF0C;&#x7136;&#x800C;&#x5B83;&#x5E76;&#x4E0D;&#x5B58;&#x5728;&#x4E8E; Person.prototype &#x4E2D;&#xFF0C;&#x5B9E;&#x9645;&#x4E0A;&#xFF0C;&#x5B83;&#x662F;&#x6765;&#x81EA;&#x4E8E; Object.prototype &#xFF0C;&#x4E0E;&#x5176;&#x8BF4;&#x662F;&#x4E00;&#x4E2A;&#x5C5E;&#x6027;&#xFF0C;&#x4E0D;&#x5982;&#x8BF4;&#x662F;&#x4E00;&#x4E2A; getter/setter&#xFF0C;&#x5F53;&#x4F7F;&#x7528; obj.__proto__ &#x65F6;&#xFF0C;&#x53EF;&#x4EE5;&#x7406;&#x89E3;&#x6210;&#x8FD4;&#x56DE;&#x4E86; Object.getPrototypeOf(obj)&#x3002;</p>
<h3 id="&#x771F;&#x7684;&#x662F;&#x7EE7;&#x627F;&#x5417;&#xFF1F;"><a name="&#x771F;&#x7684;&#x662F;&#x7EE7;&#x627F;&#x5417;&#xFF1F;" class="anchor-navigation-ex-anchor" href="#&#x771F;&#x7684;&#x662F;&#x7EE7;&#x627F;&#x5417;&#xFF1F;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x771F;&#x7684;&#x662F;&#x7EE7;&#x627F;&#x5417;&#xFF1F;</h3>
<p>&#x6700;&#x540E;&#x662F;&#x5173;&#x4E8E;&#x7EE7;&#x627F;&#xFF0C;&#x524D;&#x9762;&#x6211;&#x4EEC;&#x8BB2;&#x5230;&#x201C;&#x6BCF;&#x4E00;&#x4E2A;&#x5BF9;&#x8C61;&#x90FD;&#x4F1A;&#x4ECE;&#x539F;&#x578B;&#x2018;&#x7EE7;&#x627F;&#x2019;&#x5C5E;&#x6027;&#x201D;&#xFF0C;&#x5B9E;&#x9645;&#x4E0A;&#xFF0C;&#x7EE7;&#x627F;&#x662F;&#x4E00;&#x4E2A;&#x5341;&#x5206;&#x5177;&#x6709;&#x8FF7;&#x60D1;&#x6027;&#x7684;&#x8BF4;&#x6CD5;&#xFF0C;&#x5F15;&#x7528;&#x300A;&#x4F60;&#x4E0D;&#x77E5;&#x9053;&#x7684;JavaScript&#x300B;&#x4E2D;&#x7684;&#x8BDD;&#xFF0C;&#x5C31;&#x662F;&#xFF1A;</p>
<p>&#x7EE7;&#x627F;&#x610F;&#x5473;&#x7740;&#x590D;&#x5236;&#x64CD;&#x4F5C;&#xFF0C;&#x7136;&#x800C; JavaScript &#x9ED8;&#x8BA4;&#x5E76;&#x4E0D;&#x4F1A;&#x590D;&#x5236;&#x5BF9;&#x8C61;&#x7684;&#x5C5E;&#x6027;&#xFF0C;&#x76F8;&#x53CD;&#xFF0C;JavaScript &#x53EA;&#x662F;&#x5728;&#x4E24;&#x4E2A;&#x5BF9;&#x8C61;&#x4E4B;&#x95F4;&#x521B;&#x5EFA;&#x4E00;&#x4E2A;&#x5173;&#x8054;&#xFF0C;&#x8FD9;&#x6837;&#xFF0C;&#x4E00;&#x4E2A;&#x5BF9;&#x8C61;&#x5C31;&#x53EF;&#x4EE5;&#x901A;&#x8FC7;&#x59D4;&#x6258;&#x8BBF;&#x95EE;&#x53E6;&#x4E00;&#x4E2A;&#x5BF9;&#x8C61;&#x7684;&#x5C5E;&#x6027;&#x548C;&#x51FD;&#x6570;&#xFF0C;&#x6240;&#x4EE5;&#x4E0E;&#x5176;&#x53EB;&#x7EE7;&#x627F;&#xFF0C;&#x59D4;&#x6258;&#x7684;&#x8BF4;&#x6CD5;&#x53CD;&#x800C;&#x66F4;&#x51C6;&#x786E;&#x4E9B;&#x3002;</p>
<footer class="page-footer"><span class="copyright">Copyright &#xA9; YoungGary 2019 all right reserved&#xFF0C;powered by Gitbook</span><span class="footer-modification">&#x8BE5;&#x6587;&#x4EF6;&#x4FEE;&#x8BA2;&#x65F6;&#x95F4;&#xFF1A;
2020-01-03 16:31:06
</span></footer>
                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                <a href="bind.html" class="navigation navigation-prev " aria-label="Previous page: 3.bind的模拟实现">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
                <a href="call.html" class="navigation navigation-next " aria-label="Next page: 5.模拟实现call和apply">
                    <i class="fa fa-angle-right"></i>
                </a>
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"4.JS原型和原型链","level":"1.5.4","depth":2,"next":{"title":"5.模拟实现call和apply","level":"1.5.5","depth":2,"path":"js/call.md","ref":"js/call.md","articles":[]},"previous":{"title":"3.bind的模拟实现","level":"1.5.3","depth":2,"path":"js/bind.md","ref":"js/bind.md","articles":[]},"dir":"ltr"},"config":{"plugins":["theme-comscore","prism","-highlight","copy-code-button","search-pro","-search","-lunr","expandable-chapters","splitter","-sharing","tbfed-pagefooter","anchor-navigation-ex"],"styles":{},"pluginsConfig":{"tbfed-pagefooter":{"copyright":"Copyright &copy YoungGary 2019","modify_label":"该文件修订时间：","modify_format":"YYYY-MM-DD HH:mm:ss"},"prism":{"css":["prismjs/themes/prism-solarizedlight.css"],"lang":{"shell":"bash"}},"splitter":{},"search-pro":{},"fontsettings":{"theme":"white","family":"sans","size":2},"anchor-navigation-ex":{"associatedWithSummary":true,"float":{"floatIcon":"fa fa-navicon","level1Icon":"","level2Icon":"","level3Icon":"","showLevelIcon":false},"mode":"float","multipleH1":true,"pageTop":{"level1Icon":"","level2Icon":"","level3Icon":"","showLevelIcon":false},"printLog":false,"showGoTop":true,"showLevel":false},"theme-comscore":{},"copy-code-button":{},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false},"expandable-chapters":{}},"theme":"default","author":"Gary","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":"Gary的小窝","language":"zh-hans","gitbook":"*","description":"Gary的小窝. 里面包含了个人撰写的技术文章"},"file":{"path":"js/proto.md","mtime":"2020-01-03T08:31:06.073Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2021-09-09T14:10:10.930Z"},"basePath":"..","book":{"language":""}});
        });
    </script>
</div>

        
    <script src="../gitbook/gitbook.js"></script>
    <script src="../gitbook/theme.js"></script>
    
        
        <script src="../gitbook/gitbook-plugin-copy-code-button/toggle.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search-pro/jquery.mark.min.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search-pro/search.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-expandable-chapters/expandable-chapters.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-splitter/splitter.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-theme-comscore/test.js"></script>
        
    

    </body>
</html>

